/*渲染轮播*/
if(sessionStorage.sliderData)
{
	var datas =JSON.parse(sessionStorage.sliderData);
	vueslider = new Vue({
				el: ".slider-content",
				data: {
				sliderImgs: datas.result.carousel
			}
	})
/*new 一个轮播组件*/
	var slider = new Slider();
	slider.init({
		autoplay: true
	});
}else {
	drawSlider();
}

/*监听屏幕分辨率改变*/
$(window).resize(function(){
	slider.update();
})
function drawSlider() {
	$.ajax({
		type: "post",
		url: serviceIP + "shemhe.php/Officials/carousel",
		async: true,
		dataType: "json",
		success: function(datas) {
			sliderData = sessionStorage.sliderData = JSON.stringify(datas);
			console.log(datas);
			/*渲染轮播*/
			vueslider = new Vue({
				el: ".slider-content",
				data: {
					sliderImgs: datas.result.carousel
				}
			})
			/*new 一个轮播组件*/
			var slider = new Slider();
			slider.init({
				autoplay: true
			});
		}
	})
}
/*首页新闻*/
drawHomeNews(sessionStorage.newsData)
function drawHomeNews(newsData) {
	if(newsData){
		/*渲染轮播*/
		vueHomeNews = new Vue({
			el: ".news-wrap",
			data: {
				homeNews: JSON.parse(newsData).result.news
			}
		})
	}else {
		$.ajax({
			type: "post",
			url: serviceIP + "shemhe.php/Officials/news",
			async: true,
			dataType: "json",
			success: function(datas) {
				console.log(datas)
				newsData = sessionStorage.newsData = JSON.stringify(datas);
				/*渲染轮播*/
				vueHomeNews = new Vue({
					el: ".news-wrap",
					data: {
						homeNews: JSON.parse(newsData).result.news
					}
				})
			}
		})
	}
}


/*渲染首页案例*/
drawHomeCase(sessionStorage.caseData)
function drawHomeCase(caseData) {
	if(caseData)
	{
		/*渲染轮播*/
		vueHomeNews = new Vue({
			el: ".handpick-list",
			data: {
				homeCase: JSON.parse(caseData).result
			}
		})
	}else {
		$.ajax({
			type: "post",
			url: serviceIP + "shemhe.php/Officials/cases",
			async: true,
			dataType: "json",
			success: function(datas) {
				caseData = sessionStorage.caseData = JSON.stringify(datas);
				console.log(JSON.parse(caseData));
				/*渲染轮播*/
				vueHomeNews = new Vue({
					el: ".handpick-list",
					data: {
						homeCase: JSON.parse(caseData).result
					}
				})
			}
		})
	}
}